﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GISCore.Geometry.IO;
using GISCore.Geometry;
using GISCore.Geometry.Partition;
using GISCore.Geometry.Intersectors;
using GISCore.Geometry.Merge;

namespace GISCore
{
    class Builder
    {
        public void builder()
        {
        IFileHandler handler_base = new GMLFileHandler(Constants.baseLayerId);
        IFileHandler handler_target = new GMLFileHandler(Constants.targetLayerId);
        Layer layer_base = handler_base.Read("");
        Layer layer_target = handler_target.Read("");
        IPartitionable partitioner = new UniformGrid(4, 5);
        IDictionary<int,ICellable> cells = partitioner.Partition(layer_base, layer_target);
        IIntersector intersector = new SweepLine();
        IReconstuctionable reconstructor = new PolygonReconstuctor();
        foreach (var cell in cells.Values)
        {
            cell.setIntersectPoint(intersector.Intersect(cell.getLines()));
            //cell.setPostPolygons(reconstructor.reconstruct(cell.getLines(), cell.getIntersectPoint(), cell.getTopGridIntersectPoint(), cell.getBottomGridIntersectPoint(), cell.getLeftGridIntersectPoint(), cell.getRightGridIntersectPoint()));
        }
        IMergable merger = new LinkedMerge();
        IFileHandler handler_overlayer= new GMLFileHandler(Constants.overLayerId);
        //handler_overlayer.Write(merger.merge(cells), "");

        }

    }
}
